<template>
<view class="container" @tap="goWxapp">
  <view class="content">
    <view class="text"><lang keywords="为了更好的使用体验，我们准备了新版功能"></lang></view>
  <button class="btn" type="primary" size="mini"><lang keywords="轻触页面跳转"></lang></button>
  </view>
</view>
</template>

"<script>
var _this = this;
var app = getApp();

export default {
  data() {
    return {};
  },

  onLoad(options) {
    console.log(options);
    _this = this;
    common.setMainColor(_this);
    common.getTxtKey('页面跳转').then(key => {
      wx.setNavigationBarTitle({
        title: key
      });
    }, () => {});
    this.setData(options);

    if (options.pageTitle) {
      wx.setNavigationBarTitle({
        title: decodeURIComponent(options.pageTitle)
      });
    }

    this.goWxapp();
  },

  components: {},
  props: {},
  methods: {
    goWxapp() {
      console.log(_this.appid);
      wx.navigateToMiniProgram({
        appId: _this.appid,
        success: function (res) {
          console.log('location_wxapp ok', res);
          wx.navigateBack();
        },
        fail: function (res) {
          console.log('location_wxapp fail', res);

          if (res.errMsg.indexOf('cancel') != -1) {
            wx.navigateBack();
          }
        },
        complete: function () {}
      });
    },

    setData: function (obj) {
      let that = this;
      let keys = [];
      let val, data;
      Object.keys(obj).forEach(function (key) {
        keys = key.split('.');
        val = obj[key];
        data = that.$data;
        keys.forEach(function (key2, index) {
          if (index + 1 == keys.length) {
            that.$set(data, key2, val);
          } else {
            if (!data[key2]) {
              that.$set(data, key2, {});
            }
          }

          data = data[key2];
        });
      });
    }
  }
};
</script>
<style>
.container{
  position:absolute;
  left:0;
  width:100%;
  top:0;
  height:100%;
}
.content{
  text-align: center;
  position:absolute;
  left:0;
  width:100%;
  top:50%;
  margin-top:-80rpx;
}
.text{
  margin-bottom:50rpx;
}
</style>